(library (json-writer)
  (export put-json-to-file)
  (import (rnrs base)
          (only (guile)
                lambda* λ
                call-with-output-file)
          ;; external libraries
          (json)))


(define put-json-to-file
  (lambda* (file-location
            the-json
            #:key
            (escape-slashes #f)
            (pretty #t)
            (escape-unicode #f)
            (validate #t))
    (call-with-output-file file-location
      (λ (file-port)
        (scm->json the-json
                   file-port
                   #:solidus escape-slashes
                   #:pretty pretty
                   #:unicode escape-unicode
                   #:validate validate)))))
